package com.ryhx.pay.channel.app.paybank.dao.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Component;

import com.ryhx.pay.channel.app.model.PayBank;
import com.ryhx.pay.channel.app.paybank.dao.PayBankDao;
import com.ryhx.pay.common.exceptions.BizException;

@Component("payBankDao")
public class PayBankDaoImpl implements PayBankDao {

	@Resource(name = "sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public PayBank getPayBank(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectOne("PayBankMapper.getPayBank", query);
	}

	@Override
	public List<PayBank> getPayBankList(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectList("PayBankMapper.getPayBankList", query);
	}

	@Override
	public Integer getPayBankListCount(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.selectOne("PayBankMapper.getPayBankListCount", query);
	}

	@Override
	public int batchInsertPayBank(List<PayBank> list) throws BizException {
		return sqlSessionTemplate.insert("PayBankMapper.batchInsertPayBank", list);
	}

	@Override
	public int batchReplacePayBank(List<PayBank> list) throws BizException {
		return sqlSessionTemplate.insert("PayBankMapper.batchReplacePayBank", list);
	}

	@Override
	public int batchUpdatePayBank(List<PayBank> list) throws BizException {
		return sqlSessionTemplate.update("PayBankMapper.batchUpdatePayBank", list);
	}

	@Override
	public Long insertPayBank(PayBank payBank) throws BizException {
		sqlSessionTemplate.insert("PayBankMapper.insertPayBank", payBank);
		return payBank.getEntityId();
	}

	@Override
	public Long replacePayBank(PayBank payBank) throws BizException {
		sqlSessionTemplate.insert("PayBankMapper.replacePayBank", payBank);
		return payBank.getEntityId();
	}

	@Override
	public int updatePayBank(PayBank payBank) throws BizException {
		return sqlSessionTemplate.update("PayBankMapper.updatePayBank", payBank);
	}

	@Override
	public int updatePayBankWithoutNull(PayBank payBank) throws BizException {
		return sqlSessionTemplate.update("PayBankMapper.updatePayBankWithoutNull", payBank);
	}

	@Override
	public int updatePayBankByWhereSql(Map<String, Object> payBank) throws BizException {
		return sqlSessionTemplate.update("PayBankMapper.updatePayBankByWhereSql", payBank);
	}

	@Override
	public int truncatePayBank() throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.truncatePayBank");
	}

	@Override
	public int deletePayBank(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.deletePayBank", query);
	}

	@Override
	public int deletePayBankList(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.deletePayBankList", query);
	}

	@Override
	public int deletePayBankByWhereSql(Map<String, Object> query) throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.deletePayBankByWhereSql", query);
	}

	@Override
	public int batchDeletePayBank(List<Long> list) throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.batchDeletePayBank", list);
	}

	@Override
	public int batchDeletePayBankList(List<PayBank> list) throws BizException {
		return sqlSessionTemplate.delete("PayBankMapper.batchDeletePayBankList", list);
	}
}
